/**
 * @description 加载javascript
 * @param {string} url
 * @returns {Promise<boolean>}
 */
function loadScript(url) {
  return new Promise((resolve, reject) => {
    const script = document.createElement("script");
    script.src = url;
    script.onload = () => {
      resolve(true);
    };
    script.onerror = () => {
      reject(false);
    };
    document.body.appendChild(script);
  });
}

async function loadScripts() {
  try {
    await loadScript("./shape/ShapeEvent.js");
    await loadScript("./shape/Shape.js");
    await loadScript("./shape/ImageShape.js");
    await loadScript("./shape/BorderImageShape.js");
    await loadScript("./shape/MobileImageShape.js");
    await loadScript("./shape/TextShape.js");
    await loadScript("./shape/BasketShape.js");
    await loadScript("./shape/FruitShape.js");
    await loadScript("./shape/ScoreboardShape.js");
    await loadScript("./utils/MoblieGroup.js");
    await loadScript("./utils/Group.js");
    await loadScript("./utils/World.js");
    await loadScript("./utils/createCanvas.js");
    await loadScript("./utils/createFruit.js");
    await loadScript("./utils/theme.js");
    await loadScript("./utils/utils.js");
  } catch (error) {
    console.log(error);
  }
}
